<template>
   <div  style="height:100%;">
        <div style="height:11%;color: #444444;font-size: 36px;" >
            <div style="height:100%;color: #444444;font-size: 36px;width:1080px;margin:0 auto;font-weight:normal" class="flex flex-align-center">
               选择店铺
            </div>
        </div>
        <div class="inv-login">
           <div class="logo-box position-middle-center">
               <div class="left-logo left">
                   <div class="include flex flex-align-center flex-pack-center">
                       <p>欢迎使用库存管理系统</p>
                   </div>
               </div>
               <div class="right-user choice left">
                    <div class="title">请选择店铺</div>
                    <div class="scroll-box">
                       <div class="content">
                           <div class="store-item"  v-for="item in employeeStore"  @click="choiceStore(item)">
                               <span v-text="item.storeName"></span>
                               <span v-text="item.employeeName"></span>
                           </div>
                       </div>
                    </div>
                    <div class="forget">
                        <span @click="logout">去登录</span>
                    </div>
               </div>
           </div>
        </div>
   </div>
</template>

<script type="text/javascript">
    export default{
        data () {
            return {
                checked: true,
                phone: '', // 手机号
                password: '' ,// 密码
                employeeStore: [],
            }
        },
        methods: {
            choiceStore(item){
                sessionStorage.setItem('store', JSON.stringify(item))
                this.$http.post('authorize?storeId='+item.storeId, {}).then((res)=>{//授权
                    this.$router.push({path:'/Home'});
                })
            },
            logout(){
                this.$http.post('/logout', {}).then((res)=>{
                    localStorage.clear();
                    sessionStorage.clear();
                    this.$router.push('/login');
                }).catch((err)=>{

                })
            },
        },
        created(){
            if(JSON.parse(sessionStorage.getItem('allStore'))){
                this.employeeStore = JSON.parse(sessionStorage.getItem('allStore'));
            }else{
                this.$router.push('/login');
            }
        }
    }
</script>
<style lang="scss" scoped>
    @import '../../../static/css/common.scss';
    @import "choiceStore";
</style>
